@extends('admin.layout')
@section('title',$title)
@section('content')
    <meta name="_token" content="{{ csrf_token() }}"/>
    {{--<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.js"></script>--}}
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                商品管理
                <small>这是商品管理页</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 商品管理</a></li>
                {{--<li><a href="#"></a></li>--}}
                <li class="active">商品添加</li>
            </ol>
        </section>
        

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <!-- left column -->
                <div class="col-md-12">
                    <!-- general form elements -->
                    <div class="box box-primary">
                        <div class="box-header with-border">
                            <h3 class="box-title">商品添加</h3>
                        </div><!-- /.box-header -->
                        <!-- 添加商品表单 -->
                        <form role="form" action="/admin/goods/insert" method="post" enctype="multipart/form-data">
                            {{ csrf_field() }}
                            <div class="box-body">
                                {{--<div style="float:left">--}}
                                <label for="exampleInputEmail1" style="float:left">商品分类:&nbsp;&nbsp;</label>

                                <div class="form-group" style="width:20%;float:left">
                                    <select class="form-control" id="p" name="">
                                        <option>请选择</option>
                                        @foreach($data as $v)
                                        <option  value="{{ $v -> id }}">{{ $v -> catename }}</option>
                                        @endforeach
                                    </select>
                                    <script type="text/javascript">
//                                        alert('/admin/goods/ajax');
                                        $.ajaxSetup({
                                            headers: {
                                                'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                                            }
                                        });
                                                $('#p').on('change',function(){

                                                    var id = $(this).val();
                                                    console.log(id);
                                                    $.ajax({
                                                        type:'post',
                                                        url:"/admin/goods/ajaxCate",
                                                        data:{'id':id},
                                                        timeout:3000
                                                        ,
                                                        success:function(data)
                                                        {
                                                            console.log(data);
                                                            $("#z").empty();
                                                            var count = data.length;
                                                            var i = 0;
                                                            var b="";
                                                            b+= "<option>请选择</option>"
                                                            for(i=0;i<count;i++){
                                                                b+="<option value='"+data[i].id+"'>"+data[i].catename+"</option>";
                                                            }
                                                            $("#z").append(b);
                                                        },
                                                        dataType:'json'
                                                    });
                                                });
                                    </script>
                                </div>
                                <div class="form-group" style="width:20%;float:left">
                                    <select class="form-control" id="z" name="">
                                        <option>请选择</option>
                                    </select>
                                </div>
                                <script type="text/javascript">

                                    $.ajaxSetup({
                                        headers: {
                                            'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                                        }
                                    });

                                    $('#z').on('change',function(){

                                        var id = $(this).val();
                                        console.log(id);
//                                                    var id = 1;
                                        $.ajax({
                                            type:'post',
                                            url:"/admin/goods/ajaxCate",
                                            data:{'id':id},
                                            timeout:3000
                                            ,
                                            success:function(data)
                                            {
                                                $("#m").empty();
                                                var count = data.length;

                                                var i = 0;
                                                var b="";
                                                b+= "<option>请选择</option>"
                                                for(i=0;i<count;i++){
                                                    b+="<option value='"+data[i].id+"'>"+data[i].catename+"</option>";
                                                }
                                                $("#m").append(b);
                                            },
                                            dataType:'json'
                                        });
                                    });
                                </script>
                                <div class="form-group" style="width:20%;float:left">
                                    <select class="form-control" id="m" name="category_id">
                                        <option>请选择</option>

                                    </select>
                                {{--</div>--}}
                                </div>
                                <div class="form-group">
                                    <br><br><br>
                                    <label for="exampleInputEmail1" style="float:left">商品名称:&nbsp;&nbsp;</label>
                                    <input type="text" name="goods_name" class="form-control" id="exampleInputEmail1" placeholder="请输入商品名称" style="width:60%">
                                </div>

                                <br>
                               <!--  <div class="form-inline">
                                    <label for="exampleInputEmail1">商品编码:&nbsp;</label>
                                    <input type="text" name="goods_num" class="form-control" id="exampleInputEmail1" placeholder="请输入该商品的编码" style="width:60%">
                                </div><br> -->
                                <div class="form-inline">
                                    <label for="exampleInputEmail1">商品品牌:&nbsp;</label>
                                    <select class="form-control" name="brand" style="width:30%">
                                        @foreach($brand as $v)
                                        <option value="{{$v -> brandname}}">{{$v -> brandname}}</option>
                                        @endforeach
                                    </select>
                                </div><br>
                                <div class="form-group">
                                    <label for="exampleInputEmail1">商品属性:&nbsp;</label>
                                    <label>
                                        黑色<input type="checkbox" name="color[]" class="flat-red" value="黑色">
                                        白色<input type="checkbox" name="color[]" class="flat-red" value="白色">&nbsp;
                                        红色<input type="checkbox" name="color[]" class="flat-red" value="红色">&nbsp;
                                        绿色<input type="checkbox" name="color[]" class="flat-red" value="绿色">&nbsp;
                                        粉色<input type="checkbox" name="color[]" class="flat-red" value="粉色">&nbsp;
                                        黄色<input type="checkbox" name="color[]" class="flat-red" value="黄色">&nbsp;
                                        蓝色<input type="checkbox" name="color[]" class="flat-red" value="蓝色">&nbsp;
                                        灰色<input type="checkbox" name="color[]" class="flat-red" value="灰色">&nbsp;
                                        玫瑰红<input type="checkbox" name="color[]" class="flat-red" value="玫瑰红">&nbsp;
                                        橙色<input type="checkbox" name="color[]" class="flat-red" value="橙色"><br>
                                        尺寸:
                                        S<input type="checkbox" name="size[]" class="flat-red" value="S">&nbsp;
                                        M<input type="checkbox" name="size[]" class="flat-red" value="M">&nbsp;
                                        L<input type="checkbox" name="size[]" class="flat-red" value="L">&nbsp;
                                        XL<input type="checkbox" name="size[]" class="flat-red" value="XL">&nbsp;
                                        XXL<input type="checkbox" name="size[]" class="flat-red" value="XXL">&nbsp;
                                        3XL<input type="checkbox" name="size[]" class="flat-red" value="3XL">&nbsp;
                                        XS<input type="checkbox" name="size[]" class="flat-red" value="XS">&nbsp;
                                        4XL<input type="checkbox" name="size[]" class="flat-red" value="4XL">&nbsp;
                                    </label>

                                </div>
                                <div class="form-group">
                                    <label for="exampleInputEmail1">商品状态:&nbsp;</label>
                                    <label>
                                        推荐:<input type="checkbox" name="tuijian" class="flat-red" value="1">
                                        立即上架:<input type="checkbox" name="status" class="flat-red" value="1">
                                    </label>

                                </div>

                                <div class="form-inline">
                                    <label for="exampleInputEmail1">京东价格:&nbsp;</label>
                                    <input type="text" name="price" class="form-control" id="exampleInputEmail1" placeholder="0.00元" style="width:30%">
                                </div><br>
                                <div class="form-inline">
                                    <label for="exampleInputEmail1">商品库存:&nbsp;</label>
                                    <input type="text" name="num" class="form-control" id="exampleInputEmail1" placeholder="请输入正确商品规格" style="width:30%">
                                </div><br>


                                    <label for="exampleInputFile">商品主图:</label>
                                    <input type="file" name="goods_pic" id="exampleInputFile">
                                    <p class="help-block">请上传真实图片</p>
                                <label for="exampleInputFile">商品详情:</label>
                                <!-- 加载编辑器的容器 -->
                                <script id="container" name="describe" type="text/plain" style="width:100%;height:300px;"></script>
                                <!-- 配置文件 -->
                                <script type="text/javascript" src="{{asset('/ue/ueditor.config.js')}}"></script>
                                <!-- 编辑器源码文件 -->
                                <script type="text/javascript" src="{{asset('/ue/ueditor.all.js')}}"></script>
                                <!-- 实例化编辑器 -->
                                <script type="text/javascript">
                                    var ue = UE.getEditor('container');
                                </script>


                            </div><!-- /.box-body -->

                            <div class="box-footer">
                                <button type="submit" class="btn btn-danger">确认提交</button>
                            </div>
                        </form>
                    </div><!-- /.box -->






                </div><!--/.col (left) -->
                <!-- right column -->

            </div>   <!-- /.row -->
        </section><!-- /.content -->
    </div><!-- /.content-wrapper -->
@endsection
